package com.sky.controller.user;

import com.sky.pojo.Category;
import com.sky.pojo.Dish;
import com.sky.pojo.Setmeal;
import com.sky.result.Result;
import com.sky.service.user.MenuService;
import com.sky.vo.DishItemVO;
import com.sky.vo.DishVO;
import com.sky.vo.SetmealVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@Api(tags = "菜单相关")
@RestController
@RequiredArgsConstructor
public class MenuController {

    private final MenuService menuService;

    /**
     * 查询分类列表
     * @return
     */
    @GetMapping("user/category/list")
    @ApiOperation("查询分类列表")
    public Result queryList(){
        List<Category> list = menuService.queryList();
        return Result.success(list);
    }

    /**
     * 根据分类id查询菜品
     */
    @ApiOperation("根据分类id查询菜品")
    @GetMapping("/user/dish/list")
    public Result queryDishList(Long categoryId){
        List<DishVO> dishVOS = menuService.queryDishList(categoryId);
        log.info("查询回的结果集:{}",dishVOS);
        return Result.success(dishVOS);
    }

    /**
     * 根据分类id查询套餐
     */
    @ApiOperation("根据分类id查询套餐")
    @GetMapping("/user/setmeal/list")
    public Result querySetmealList(Integer categoryId){
        List<Setmeal> setmeals = menuService.querySetmealList(categoryId);
        return Result.success(setmeals);
    }

    /**
     * 根据套餐id查询包含的菜品
     */
    @GetMapping("/user/setmeal/dish/{setmealId}")
    @ApiOperation("根据套餐id查询包含的菜品")
    public Result queryDishBySId(@PathVariable Integer setmealId){
        List<DishItemVO> dishItemVOS = menuService.queryDishBySId(setmealId);
        return Result.success(dishItemVOS);
    }
}
